package operation.Jihe;

public class Student implements Comparable<Student>{
    /*4. 十三、分别用Comparable和Comparator两个接口对下列四位同学的成绩做降序排序，
如果成绩一样，那在成绩排序的基础上按照年龄由小到大排序。
姓名（String）	年龄（int）	分数（double）
liusan	          20	92.2
lisi		      22	91.8
wangwu		      20	99.0
sunliu		      22	100.0*/
    private String name;
    private int age;
    private int score;

    public Student(String name, int age, int score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    public Student() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        int rt=o.score - this.score;
        rt=rt==0 ? o.age-this.age:rt;
        return rt;
    }
}
